set(LLAMA_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../lib/llama)

function(find_llama)
    find_package(llama CONFIG REQUIRED PATHS ${LLAMA_ROOT_DIR} NO_DEFAULT_PATH)
    if (NOT llama_FOUND)
        message(FATAL_ERROR "Llama library not found. Please set LLAMA_ROOT_DIR to the correct path.")
    endif()
endfunction(find_llama)

function(install_llama dest_dir)
    if (APPLE)
        file(GLOB_RECURSE LIB_FILES "${LLAMA_ROOT_DIR}/lib/*.dylib")
        install(FILES ${LIB_FILES} DESTINATION ${dest_dir})
    elseif (UNIX)
        file(GLOB_RECURSE LIB_FILES "${LLAMA_ROOT_DIR}/lib/*.so")
        install(FILES ${LIB_FILES} DESTINATION ${dest_dir})
    elseif (WIN32)
        file(GLOB_RECURSE LIB_FILES "${LLAMA_ROOT_DIR}/bin/*.dll")
        install(FILES ${LIB_FILES} DESTINATION ${dest_dir})
    endif()
endfunction(install_llama)
